package ua.kpi_java_training.tyshchenko.module2;

/**
 * Class does all the actions of the victims: move, considers the number of move
 * and check appearance of new fish
 *
 * @author Vlad Tyshchenko
 * @version 1.1 3 June 2013
 */
public class Victim extends CreatureInHabitat {
    /**
     * LENGTH_STEP - amount of steps per cycle
     */
    final private int LENGTH_STEP = 1;
    final private int COUNT_STEP = 3;
    private int countLife = 0;
    Habitat habitat;

    /**
     * @param habitat
     */
    public Victim(Habitat habitat) {
        super(habitat);
        this.habitat = habitat;
    }

    public void move() {
        super.move(LENGTH_STEP);
        addCountNewLife();
    }


    public void addCountNewLife() {
        countLife++;
    }

    /**
     * @return true if victim does 'COUNT_STEP' steps
     */
    public boolean checkBirth() {
        return (countLife % COUNT_STEP == 0 && countLife != 0) ? true : false;
    }

    public CreatureInHabitat getNewFish() {
        return new Victim(habitat);
    }

    public KindOfCreatures getKeyCreature() {
        return KindOfCreatures.victim;
    }

}
